package com.prs.crm.action.hr;


import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;

import com.prs.crm.annotation.Clew;
import com.prs.crm.domain.hr.CheckPlan;

import com.prs.crm.service.hr.CheckPlanService;


public class CheckPlanAction extends BaseAction{
	
	private static final long serialVersionUID = 1L;
	
	private CheckPlan checkPlan;
    private CheckPlanService  checkPlanService;
    private List<CheckPlan> checkPlans;
    
	private PaginationSupport pagination;
	private Integer[] checkPlanIds;
    private String beginTime;
    private String endTime;
	
	public CheckPlanService getCheckPlanService() {
		return checkPlanService;
	}


	public void setCheckPlanService(CheckPlanService checkPlanService) {
		this.checkPlanService = checkPlanService;
	}
	public CheckPlan getCheckPlan() {
		return checkPlan;
	}


	public void setCheckPlan(CheckPlan checkPlan) {
		this.checkPlan = checkPlan;
	}


	public PaginationSupport getPagination() {
		return pagination;
	}


	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	
	public Integer[] getCheckPlanIds() {
		return checkPlanIds;
	}


	public void setCheckPlanIds(Integer[] checkPlanIds) {
		this.checkPlanIds = checkPlanIds;
	}


	
	public static long getSerialVersionUID() {
		return serialVersionUID;
	}
	
	@Action("editCheckPlan")
	public String editCheckPlan(){	
		checkPlans=this.getCheckPlanService().getAllCheckPlan();
		return SUCCESS;
	}
	
	@Clew(results={"success"})
	@Action(value="saveCheckPlan",results={@Result(name="success",type="redirect",location="editCheckPlan"),
			@Result(name="error",type="chain",location="editCheckPlan")})
	public String saveCheckPlan()
	{
		checkPlans=this.getCheckPlanService().getAllCheckPlan();
	   
		     if(checkPlans.size()>0){

				this.addActionError("已设置！");
				 return ERROR;

		}
				
		this.getCheckPlanService().save(checkPlan);
		this.setPrompt("提交成功");
		return SUCCESS;	
		
	}
	
	
	@Action("viewCheckPlan")
	public String view() {
		return SUCCESS;
	}


	public List<CheckPlan> getCheckPlans() {
		return checkPlans;
	}


	public void setCheckPlans(List<CheckPlan> checkPlans) {
		this.checkPlans = checkPlans;
	}


	public String getBeginTime() {
		return beginTime;
	}


	public void setBeginTime(String beginTime) {
		this.beginTime = beginTime;
	}


	public String getEndTime() {
		return endTime;
	}


	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	//SimpleDateFormat df = new SimpleDateFormat("HH:mm");//设置日期格式
	
}
